# -*- coding:utf-8 -*-
class Solution:
    def maxInWindows(self, num, size):
        # write code here
        n = len(num)
        if n==0 or size==0 or size>n:
            return []
        res = []
        tmp = []
        for i in range(n):
            if len(tmp)>0 and i - size >= tmp[i]:
                tmp.pop(0)
            while len(tmp)>0 and num[i] > num[tmp[i]]:
                tmp.pop()
            tmp.append(i)
            if i > size-1:
                res.append(num[tmp[0]])
        return  res